<template>
	<section>
		<!--工具条-->
		<el-col :span="24" class="toolbar" style="padding-bottom: 0px;">
			<el-form :inline="true" :model="filters">
				<el-form-item>
					<el-input v-model="filters.keyWord" placeholder="关键词" clearable></el-input>
				</el-form-item>
				<el-form-item>
					<el-input v-model="filters.mobile" placeholder="手机号" clearable></el-input>
				</el-form-item>
				<el-form-item label="会员类型">
		            <el-select v-model="filters.vipType" clearable> 
		                <el-option v-for="item in option" :key="item.value" :label="item.label" :value="item.value"></el-option>
		            </el-select>
			    </el-form-item>
				<el-form-item>
					<el-button type="primary" size="medium" v-on:click="handleCurrentChange(1)">查询</el-button>
				</el-form-item>
			</el-form>
		</el-col>

		<!--列表-->
		<el-table :data="users" stripe highlight-current-row v-loading="listLoading" border style="width: 100%;">
			<el-table-column prop="nickname" label="昵称" min-width="80" align="center">
			</el-table-column>
			<el-table-column prop="mobile" label="手机号码" min-width="80" align="center">
			</el-table-column>
			<el-table-column prop="vipType" label="会员类型" min-width="80" align="center">
				<template slot-scope="scope">
					<span>{{scope.row.vipType===1?'plus会员' :scope.row.vipType===2?'代理商' :scope.row.vipType===3?'合伙人' :'股东'}}</span>
				</template>
			</el-table-column>
			<el-table-column prop="byPrice" label="会员价格" min-width="80" align="center">
			</el-table-column>
			<el-table-column prop="payTime" label="开通时间" :formatter="formatDate" min-width="110" align="center">
			</el-table-column>
		</el-table>

		<!--工具条-->
		<el-col :span="24" class="toolbar">
			<el-pagination background layout="prev, pager, next, jumper" @current-change="handleCurrentChange" :page-size="pageSize" :total="total" style="float:right;">
			</el-pagination>
		</el-col>
	</section>
</template>

<script>
	import util from '../../common/js/util'
	
	export default {
		data() {
			return {
				filters: {
					keyWord: '',
					mobile:'',
					vipType:''
				},
				users: [],
				total: 0,
				page: 1,
				pageSize: 10,
				listLoading: false,
				option:[{
					value:1,
					label:'plus会员'
				},{
					value:2,
					label:'代理商'
				},{
					value:3,
					label:'合伙人'
				},{
					value:4,
					label:'股东'
				}]
			}
		},
		methods: {
			//时间转换开始时间 
			formatDate(row, column) {
                let date = new Date(parseInt(row.payTime));
                let Y = date.getFullYear() + '-';
                let M = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) + '-' : date.getMonth() + 1 + '-';
                let D = date.getDate() < 10 ? '0' + date.getDate() + ' ' : date.getDate() + ' ';
                let h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
                let m = date.getMinutes()  < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
                let s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
                return Y + M + D + h + m + s;
            },
			handleCurrentChange(val) {
				this.page = val;
				this.getUsers();
			},
			//获取列表
			getUsers:function (){
				this.listLoading = true;
				let para = {
					page: this.page,
					size: this.pageSize,
					keyWord: this.filters.keyWord,
					mobile: this.filters.mobile,
					vipType: this.filters.vipType,
				};
				var instance = this.$http.create({headers: {'content-type': 'application/x-www-form-urlencoded','admin_five_palace_token':JSON.parse(sessionStorage.getItem('token'))},
				});  
				instance.post('admin/order/getVipByRecordsList', this.qs.stringify(para)).then(data => {
					
					let  res = data.data;
					if (res.code !== 0) {
						this.$message({
							message: res.msg,
							type: 'error'
						});
					} else {
						this.total = res.total;
						this.users = res.rows;
						this.listLoading = false;
					}
				});
			},
			
		},
		mounted() {
			this.getUsers();
		}
	}

</script>

<style scoped>

</style>